<html>
<head>
  <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1">
  <title>ppatterns.m</title>
<link rel="stylesheet" type="text/css" href="../../m-syntax.css">
</head>
<body>
<code>
<span class=defun_kw>function</span>&nbsp;<span class=defun_out>varargout</span>=<span class=defun_name>ppatterns</span>(<span class=defun_in>data,arg1,arg2</span>)<br>
<span class=h1>%&nbsp;PPATTERNS&nbsp;Plots&nbsp;pattern&nbsp;as&nbsp;points&nbsp;in&nbsp;feature&nbsp;space.</span><br>
<span class=help>%&nbsp;</span><br>
<span class=help>%&nbsp;<span class=help_field>Synopsis:</span></span><br>
<span class=help>%&nbsp;&nbsp;ppatterns(data,marker_size)</span><br>
<span class=help>%&nbsp;&nbsp;ppatterns(data,'num')</span><br>
<span class=help>%&nbsp;&nbsp;ppatterns(X,marker,marker_size)</span><br>
<span class=help>%&nbsp;&nbsp;ppatterns(X,y)</span><br>
<span class=help>%&nbsp;&nbsp;ppatterns(X,y,marker_size)</span><br>
<span class=help>%&nbsp;&nbsp;ppatterns(X,y,'num')</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Description:</span></span><br>
<span class=help>%&nbsp;&nbsp;ppatterns(data,marker_size)&nbsp;plots&nbsp;data.X&nbsp;as&nbsp;points</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;distinguished&nbsp;by&nbsp;marker&nbsp;and&nbsp;its&nbsp;color&nbsp;according&nbsp;to&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;given&nbsp;labels&nbsp;data.y.&nbsp;The&nbsp;marker&nbsp;size&nbsp;can&nbsp;be&nbsp;prescribed.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;&nbsp;ppatterns(data,'num')&nbsp;plots&nbsp;data.X&nbsp;in&nbsp;distinguished&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;by&nbsp;numbers&nbsp;and&nbsp;colors&nbsp;according&nbsp;to&nbsp;given&nbsp;labels&nbsp;data.y.&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;The&nbsp;marker&nbsp;size&nbsp;can&nbsp;be&nbsp;determined&nbsp;by&nbsp;argument&nbsp;marker_size.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;&nbsp;ppatterns(X,marker,marker_size)&nbsp;plots&nbsp;data&nbsp;X.&nbsp;Marker&nbsp;type</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;can&nbsp;be&nbsp;determined&nbsp;by&nbsp;argument&nbsp;marker.&nbsp;The&nbsp;marker&nbsp;size&nbsp;can&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;be&nbsp;determined&nbsp;by&nbsp;argument&nbsp;marker_size.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;&nbsp;ppatterns(X,y,...)&nbsp;instead&nbsp;of&nbsp;structure&nbsp;data,&nbsp;which&nbsp;contains</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;items&nbsp;X&nbsp;and&nbsp;y&nbsp;these&nbsp;can&nbsp;enter&nbsp;the&nbsp;function&nbsp;directly.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;&nbsp;If&nbsp;dimension&nbsp;of&nbsp;input&nbsp;data&nbsp;is&nbsp;greater&nbsp;than&nbsp;3&nbsp;then</span><br>
<span class=help>%&nbsp;&nbsp;only&nbsp;first&nbsp;3&nbsp;dimensions&nbsp;are&nbsp;assumed&nbsp;and&nbsp;data&nbsp;are&nbsp;plotted&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;in&nbsp;3D&nbsp;space.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Output:</span></span><br>
<span class=help>%&nbsp;&nbsp;H&nbsp;[struct]&nbsp;Handles&nbsp;of&nbsp;used&nbsp;graphical&nbsp;objects.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Example:</span></span><br>
<span class=help>%&nbsp;&nbsp;data&nbsp;=&nbsp;load('riply_trn');&nbsp;&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;figure;&nbsp;ppatterns(data);</span><br>
<span class=help>%&nbsp;&nbsp;figure;&nbsp;ppatterns(data,'num');</span><br>
<span class=help>%&nbsp;&nbsp;figure;&nbsp;ppatterns(data.X,'xk',10);</span><br>
<span class=help>%&nbsp;&nbsp;</span><br>
<span class=help>%&nbsp;See&nbsp;also&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;PLINE.</span><br>
<span class=help>%</span><br>
<hr>
<span class=help1>%&nbsp;<span class=help1_field>About:</span>&nbsp;Statistical&nbsp;Pattern&nbsp;Recognition&nbsp;Toolbox</span><br>
<span class=help1>%&nbsp;(C)&nbsp;1999-2003,&nbsp;Written&nbsp;by&nbsp;Vojtech&nbsp;Franc&nbsp;and&nbsp;Vaclav&nbsp;Hlavac</span><br>
<span class=help1>%&nbsp;&lt;a&nbsp;href="http://www.cvut.cz"&gt;Czech&nbsp;Technical&nbsp;University&nbsp;Prague&lt;/a&gt;</span><br>
<span class=help1>%&nbsp;&lt;a&nbsp;href="http://www.feld.cvut.cz"&gt;Faculty&nbsp;of&nbsp;Electrical&nbsp;Engineering&lt;/a&gt;</span><br>
<span class=help1>%&nbsp;&lt;a&nbsp;href="http://cmp.felk.cvut.cz"&gt;Center&nbsp;for&nbsp;Machine&nbsp;Perception&lt;/a&gt;</span><br>
<br>
<span class=help1>%&nbsp;<span class=help1_field>Modifications:</span></span><br>
<span class=help1>%&nbsp;25-may-2004,&nbsp;VF</span><br>
<span class=help1>%&nbsp;11-mar-2004,&nbsp;VF,&nbsp;</span><br>
<span class=help1>%&nbsp;5-oct-2003,&nbsp;VF,&nbsp;returns&nbsp;handles</span><br>
<span class=help1>%&nbsp;12-feb-2003,&nbsp;VF,&nbsp;1D,&nbsp;3D&nbsp;added</span><br>
<span class=help1>%&nbsp;7-jan-2003,&nbsp;VF,&nbsp;created</span><br>
<br>
<hr>
oldhold&nbsp;=&nbsp;ishold;<br>
hold&nbsp;on;<br>
<br>
<span class=comment>%&nbsp;takes&nbsp;care&nbsp;of&nbsp;the&nbsp;case&nbsp;when&nbsp;X,y&nbsp;is&nbsp;used&nbsp;insted&nbsp;of&nbsp;structure&nbsp;data</span><br>
<span class=comment>%&nbsp;ppatterns(X,y,...)&nbsp;-&gt;&nbsp;ppatterns(data,...)</span><br>
<span class=keyword>if</span>&nbsp;<span class=stack>nargin</span>&nbsp;&gt;&nbsp;1&nbsp;&&nbsp;~isstruct(data)&nbsp;&&nbsp;size(data,2)==length(arg1)&nbsp;&&nbsp;~isstr(arg1),<br>
&nbsp;&nbsp;data.X=data;<br>
&nbsp;&nbsp;data.y=arg1;<br>
&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;<span class=stack>nargin</span>&nbsp;&gt;=&nbsp;3,&nbsp;H=ppatterns(data,arg2);&nbsp;<span class=keyword>else</span>&nbsp;H=ppatterns(data);&nbsp;<span class=keyword>end</span>&nbsp;<br>
&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;<span class=stack>nargout</span>&nbsp;&gt;=&nbsp;1,&nbsp;<span class=stack>varargout</span>{1}=H;&nbsp;<span class=keyword>end</span><br>
&nbsp;&nbsp;<span class=jump>return</span>;<br>
<span class=keyword>end</span><br>
<br>
<span class=comment>%&nbsp;ppatterns(data)&nbsp;or&nbsp;ppatterns(data,marker_size)&nbsp;</span><br>
<span class=keyword>if</span>&nbsp;isstruct(data)&nbsp;==&nbsp;1&nbsp;&&nbsp;(<span class=stack>nargin</span>&nbsp;&lt;&nbsp;2&nbsp;|&nbsp;isstr(arg1)==0),<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;<span class=stack>nargin</span>&nbsp;&lt;&nbsp;2,&nbsp;marker_size&nbsp;=&nbsp;6;&nbsp;<span class=keyword>else</span>&nbsp;marker_size&nbsp;=&nbsp;arg1;&nbsp;<span class=keyword>end</span><br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;H&nbsp;=&nbsp;[];<br>
&nbsp;&nbsp;<span class=keyword>for</span>&nbsp;i&nbsp;=&nbsp;min(data.y):max(data.y),<br>
&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;inx&nbsp;=&nbsp;find(data.y&nbsp;==&nbsp;i);<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;~isempty(inx),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;size(data.X,1)==1,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;=&nbsp;<span class=graph>plot</span>(data.X(1,inx),zeros(1,length(inx)),marker_type(i));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>elseif</span>&nbsp;size(data.X,1)==2,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;=&nbsp;<span class=graph>plot</span>(data.X(1,inx),data.X(2,inx),marker_type(i));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>else</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;=&nbsp;plot3(data.X(1,inx),data.X(2,inx),data.X(3,inx),marker_type(i));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>end</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=graph>set</span>(h,<span class=quotes>'Color'</span>,marker_color(i));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=graph>set</span>(h,<span class=quotes>'MarkerSize'</span>,marker_size);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H&nbsp;=&nbsp;[H,&nbsp;h];<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>end</span><br>
&nbsp;&nbsp;<span class=keyword>end</span><br>
<span class=comment>%&nbsp;ppatterns(data,marker)</span><br>
<span class=keyword>elseif</span>&nbsp;isstruct(data)&nbsp;==&nbsp;1&nbsp;&&nbsp;<span class=stack>nargin</span>&nbsp;==&nbsp;2&nbsp;&&nbsp;isstr(arg1)==1&nbsp;&&nbsp;strcmpi(arg1,<span class=quotes>'num'</span>),<br>
<br>
&nbsp;&nbsp;marker_size&nbsp;=&nbsp;12;<br>
&nbsp;&nbsp;H_Points&nbsp;=&nbsp;[];<br>
&nbsp;&nbsp;H_Num&nbsp;=&nbsp;[];<br>
&nbsp;&nbsp;<span class=keyword>for</span>&nbsp;i&nbsp;=&nbsp;min(data.y):max(data.y),<br>
&nbsp;&nbsp;&nbsp;&nbsp;inx&nbsp;=&nbsp;find(data.y==i);<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;~isempty(inx),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;size(data.X,1)==1,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;=&nbsp;<span class=graph>plot</span>(data.X(1,inx),zeros(1,length(inx)),<span class=quotes>'o'</span>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>elseif</span>&nbsp;size(data.X,1)==2,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;=&nbsp;<span class=graph>plot</span>(data.X(1,inx),data.X(2,inx),<span class=quotes>'o'</span>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>else</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;=&nbsp;plot3(data.X(1,inx),data.X(2,inx),data.X(3,inx),<span class=quotes>'o'</span>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>end</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=graph>set</span>(h,<span class=quotes>'Color'</span>,marker_color(i));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=graph>set</span>(h,<span class=quotes>'MarkerSize'</span>,marker_size);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H_Points&nbsp;=&nbsp;[H_Points,&nbsp;h&nbsp;];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;size(data.X,1)==1,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;=&nbsp;text(data.X(1,inx),zeros(1,length(inx)),num2str(i));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>elseif</span>&nbsp;size(data.X,1)==2,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;=&nbsp;text(data.X(1,inx),data.X(2,inx),num2str(i));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>else</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;=&nbsp;text(data.X(1,inx),data.X(2,inx),data.X(3,inx),num2str(i));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>end</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=graph>set</span>(h,<span class=quotes>'HorizontalAlignment'</span>,<span class=quotes>'center'</span>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=graph>set</span>(h,<span class=quotes>'VerticalAlignment'</span>,<span class=quotes>'middle'</span>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=graph>set</span>(h,<span class=quotes>'Color'</span>,marker_color(i));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=graph>set</span>(h,<span class=quotes>'FontSize'</span>,marker_size-2);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H_Num&nbsp;=&nbsp;[H_Num,&nbsp;h(:)'];<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>end</span><br>
&nbsp;&nbsp;<span class=keyword>end</span><br>
&nbsp;&nbsp;H&nbsp;=&nbsp;[H_Points,&nbsp;H_Num];<br>
<span class=keyword>else</span><br>
&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;<span class=stack>nargin</span>&nbsp;&lt;&nbsp;2,&nbsp;marker&nbsp;=&nbsp;<span class=quotes>'kx'</span>;&nbsp;<span class=keyword>else</span>&nbsp;marker&nbsp;=&nbsp;arg1;&nbsp;<span class=keyword>end</span><br>
&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;<span class=stack>nargin</span>&nbsp;&lt;&nbsp;3,&nbsp;marker_size&nbsp;=&nbsp;6;&nbsp;<span class=keyword>else</span>&nbsp;marker_size&nbsp;=&nbsp;arg2;&nbsp;<span class=keyword>end</span><br>
&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;size(data,1)==1,<br>
&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;=&nbsp;<span class=graph>plot</span>(data(1,:),zeros(1,size(data,2)),marker);<br>
&nbsp;&nbsp;<span class=keyword>elseif</span>&nbsp;size(data,1)==2,<br>
&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;=&nbsp;<span class=graph>plot</span>(data(1,:),data(2,:),marker);<br>
&nbsp;&nbsp;<span class=keyword>else</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;=&nbsp;plot3(data(1,:),data(2,:),data(3,:),marker);<br>
&nbsp;&nbsp;<span class=keyword>end</span><br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;H&nbsp;=&nbsp;h;<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;<span class=graph>set</span>(h,<span class=quotes>'MarkerSize'</span>,marker_size);<br>
<span class=keyword>end</span><br>
<br>
<span class=keyword>if</span>&nbsp;oldhold,<br>
&nbsp;&nbsp;hold&nbsp;on;<br>
<span class=keyword>else</span><br>
&nbsp;&nbsp;hold&nbsp;off;<br>
<span class=keyword>end</span><br>
<br>
<span class=keyword>if</span>&nbsp;<span class=stack>nargout</span>&gt;=1,&nbsp;<span class=stack>varargout</span>{1}&nbsp;=&nbsp;H;&nbsp;<span class=keyword>end</span><br>
<br>
<span class=jump>return</span>;<br>
<br>
<br>
</code>
